package com.anhry.app.safety.manage.tjfx.struts.action;

import java.io.ByteArrayOutputStream;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.CellRangeAddress;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.CreationHelper;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.anhry.app.safety.manage.system.bean.TbUser;
import com.anhry.app.safety.manage.system.bean.TbUserDept;
import com.anhry.app.safety.manage.tjfx.bean.vo.ChartParamBean;
import com.anhry.app.safety.manage.tjfx.struts.base.ExportExcel;
import com.anhry.app.safety.manage.tjfx.struts.base.TjfxBaseAction;
import com.anhry.app.safety.util.Loggers;
import com.anhry.app.safety.util.Util;
import com.anhry.app.safety.util.UtilMethod;

/**
 * @date:2012-11-26
 * @remark:自查自报统计分析
 * @author:dongbin
 */
@Controller
@Scope("prototype")
@SuppressWarnings("unchecked")
public class TjZczbAction extends TjfxBaseAction{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private static Logger logger = Logger.getLogger(TjZczbAction.class);
	
	private String cYear;
	private String cMonth;
	private String cType;//1：区县2：行业3：企业类型4：企业级别 5:单一区县6：单一行业7：单一企业类型8：单一企业级别
	private String tjType;//
	private String titleName;//表格属性名称
	private String tjName;//统计类型名称
	private String exportExcelFlag;// 是否导出excel 如果导出excel，则返回null 否则返回success
	private StringBuffer yingBao1 = new StringBuffer();//应报企业数（规模以上）
	private StringBuffer yingBao2 = new StringBuffer();//应报企业数（小微企业）
	private StringBuffer yiBao1 = new StringBuffer();//已报企业数据（规模以上）
	private StringBuffer yiBao2 = new StringBuffer();//已报企业数（小微企业）
	private StringBuffer yhSql1 = new StringBuffer();//隐患数（规模以上）
	private StringBuffer yhSql2 = new StringBuffer();//隐患数（小微企业）
	private StringBuffer nyhSql1 = new StringBuffer();//无隐患企业数（规模以上）
	private StringBuffer nyhSql2 = new StringBuffer();//无隐患企业数（小微企业）
	private StringBuffer wyhSql1 = new StringBuffer();//未处理隐患企业数（规模以上）
	private StringBuffer wyhSql2 = new StringBuffer();//未处理隐患企业数（小微企业）
	
	private StringBuffer ybYhSql1 = new StringBuffer();//一般隐患数
	private StringBuffer ybYhSql2 = new StringBuffer();//一般隐患整改数
	private StringBuffer bigYhSql1 = new StringBuffer();//重大隐患数
	private StringBuffer bigYhSql2 = new StringBuffer();//重大隐患整改数

	private List htmlList;
	private Map<Object[],List> htmlMap;
	private List objList;
	private List sumList;
	private String selId;
	private List yearList;
	private ChartParamBean chartbean;
	private String xmlString;
	
	/**
	 * 上报情况统计
	 * @return
	 */
	public String zczbTj(){
		try {
			if(null!=cType && this.cType.length()>0){
				int temp = Integer.parseInt(this.cType);
				switch (temp) {
				case 1:
					this.setTitleName("属地名称");
					this.setTjName("按照属地统计");
					chartbean  = new ChartParamBean("自查自报 : 上报企业数（属地）汇总","属地","已报企业数量","自查自报 : 上报企业数（属地）汇总");//页面生成xml所需参数
					this.initZczbSql("county_id", "");
					this.resultZczb(this.getSdSql("1",""), yingBao1.toString(), yingBao2.toString(), yiBao1.toString(), yiBao2.toString(), yhSql1.toString(),
							yhSql2.toString(), nyhSql1.toString(), nyhSql2.toString(), wyhSql1.toString(), wyhSql2.toString());
					break;
				case 2:
					this.setTitleName("行业名称");
					this.setTjName("按照行业统计");
					chartbean  = new ChartParamBean("自查自报 : 上报企业数（行业）汇总","行业","已报企业数量","自查自报 : 上报企业数（行业）汇总");//页面生成xml所需参数
					this.initZczbSql("dept_main_id", "");
					this.resultZczb(this.getHySql(), yingBao1.toString(), yingBao2.toString(), yiBao1.toString(), yiBao2.toString(), yhSql1.toString(),
							yhSql2.toString(), nyhSql1.toString(), nyhSql2.toString(), wyhSql1.toString(), wyhSql2.toString());
					break;
				case 3:
					this.setTitleName("企业类型");
					this.setTjName("按照企业类型统计");
					chartbean  = new ChartParamBean("自查自报 : 上报企业数（企业类型）汇总","行业","已报企业数量","自查自报 : 上报企业数（企业类型）汇总");//页面生成xml所需参数
					this.initZczbSql("max_type_id", "");
					this.resultZczb(this.getTypeSql(), yingBao1.toString(), yingBao2.toString(), yiBao1.toString(), yiBao2.toString(), yhSql1.toString(),
							yhSql2.toString(), nyhSql1.toString(), nyhSql2.toString(), wyhSql1.toString(), wyhSql2.toString());
					break;
				case 4:
					this.setTitleName("企业级别");
					this.setTjName("按照企业级别统计");
					chartbean  = new ChartParamBean("自查自报 : 上报企业数（企业级别）汇总","行业","已报企业数量","自查自报 : 上报企业数（企业级别）汇总");//页面生成xml所需参数
					this.initZczbSql("corp_grade", "");
					this.resultZczb(this.getGradeSql(), yingBao1.toString(), yingBao2.toString(), yiBao1.toString(), yiBao2.toString(), yhSql1.toString(),
							yhSql2.toString(), nyhSql1.toString(), nyhSql2.toString(), wyhSql1.toString(), wyhSql2.toString());
					break;

				default:
					break;
				}
			}
			this.setYearList(UtilMethod.getYearList(2012));
			this.setResult("zczb_tj");
			if (exportExcelFlag == null || exportExcelFlag.equals("")) {
				return SUCCESS;
			} else {
				return null;
			}
		} catch (Exception e) {
			e.printStackTrace();
			Loggers.error("tjfx:TjZczbAction zczbTj() "+e.getMessage());
		}
		return ERROR;
	}
	
	/**
	 * 隐患数统计
	 * @return
	 */
	public String yhTj(){
		try {
			if(null!=cType && this.cType.length()>0){
				int temp = Integer.parseInt(this.cType);
				switch (temp) {
				case 1:
					this.setTitleName("属地名称");
					this.setTjName("按照属地统计");
					chartbean  = new ChartParamBean("自查自报 : 上报隐患数（属地）汇总","属地","上报隐患数","自查自报 : 上报隐患数（属地）汇总");//页面生成xml所需参数
					this.initYhSql("county_id", "");
					this.resultYh(this.getSdSql("1",""),ybYhSql1.toString(),ybYhSql2.toString(),bigYhSql1.toString(),bigYhSql2.toString());
					break;
				case 2:
					this.setTitleName("行业名称");
					this.setTjName("按照行业统计");
					chartbean  = new ChartParamBean("自查自报 : 上报隐患数（行业）汇总","行业","上报隐患数","自查自报 : 上报隐患数（行业）汇总");//页面生成xml所需参数
					this.initYhSql("dept_main_id", "");
					this.resultYh(this.getHySql(),ybYhSql1.toString(),ybYhSql2.toString(),bigYhSql1.toString(),bigYhSql2.toString());
					break;
				case 3:
					this.setTitleName("企业类型");
					this.setTjName("按照企业类型统计");
					chartbean  = new ChartParamBean("自查自报 : 上报隐患数（企业类型）汇总","企业类型","上报隐患数","自查自报 : 上报隐患数（企业类型）汇总");//页面生成xml所需参数
					this.initYhSql("max_type_id", "");
					this.resultYh(this.getTypeSql(),ybYhSql1.toString(),ybYhSql2.toString(),bigYhSql1.toString(),bigYhSql2.toString());
					break;
				case 4:
					this.setTitleName("企业级别");
					this.setTjName("按照企业级别统计");
					chartbean  = new ChartParamBean("自查自报 : 上报隐患数（企业级别）汇总","企业类型","上报隐患数","自查自报 : 上报隐患数（企业级别）汇总");//页面生成xml所需参数
					this.initYhSql("corp_grade", "");
					this.resultYh(this.getGradeSql(),ybYhSql1.toString(),ybYhSql2.toString(),bigYhSql1.toString(),bigYhSql2.toString());
					break;
				case 5:
					this.setTitleName("年份月份");
					this.setTjName("按照年份月份统计");
					chartbean  = new ChartParamBean("自查自报 : 上报隐患数（年份月份）汇总","年/月","上报隐患数","自查自报 : 上报隐患数（年份月份）汇总");//页面生成xml所需参数
					this.yhStaticSql();
					String dateSql = "select distinct(t.hzd_year|| '年/' || t.hzd_month||'月'),t.hzd_year|| '年/' || t.hzd_month||'月' from TB_TJ_ZCZB_HZD_VIEW t order by t.hzd_year|| '年/' || t.hzd_month||'月' desc";
					this.resultYh(dateSql,ybYhSql1.toString(),ybYhSql2.toString(),bigYhSql1.toString(),bigYhSql2.toString());
					break;
				default:
					break;
				}
			}
			this.setYearList(UtilMethod.getYearList(2012));
			this.setResult("yh_tj");
			if (exportExcelFlag == null || exportExcelFlag.equals("")) {
				return SUCCESS;
			} else {
				return null;
			}
		} catch (Exception e) {
			e.printStackTrace();
			Loggers.error("tjfx:TjZczbAction yhTj() "+e.getMessage());
		}
		return ERROR;
	}
	
	/**
	 * 封装统计sql
	 * @param type 按照什么去分组 如区县，乡镇，企业类型，企业级别等
	 * @param str 查询条件是什么 如按照属地统计，只统计东营区乡镇的上报情况，或者按照企业类型，统计危险化学品类下各区县的上报情况
	 */
	public void initZczbSql(String type,String str){
		TbUser user = (TbUser) this.contextPvd.getSessionAttr(Util.SESSION_ADMINUSER);
		String  gradeId = user.getTbUserGrade().getId().toString();
		
		//应报企业数
		yingBao1.append("select t."+type+", count(*) from tb_corp_info_view t where t."+type+">0 and t.corp_report_type=1 and t.corp_Size=1");//规模以上
		yingBao2.append("select t."+type+", count(*) from tb_corp_info_view t where t."+type+">0 and t.corp_report_type=2 and t.corp_Size=1");//小微企业
		
		//已报企业数
		yiBao1.append("select t."+type+", count(distinct(t.corp_id)) from tb_tj_zczb_hzd_view t where 1=1 and t.corp_Size=1");//规模以上
		yiBao2.append("select t."+type+", count(distinct(t.corp_id)) from tb_tj_zczb_xwhzd_view t where 1=1 and t.corp_Size=1");//小微企业
		
		//上报隐患数
		yhSql1.append("select t."+type+", sum(t.hzd_yh_num) from tb_tj_zczb_hzd_view t where 1=1");
		yhSql2.append("select t."+type+", sum(t.hzd_yh_num) from tb_tj_zczb_xwhzd_view t where 1=1");
		
		//无隐患企业数
		nyhSql1.append("select t."+type+", count(*) from tb_tj_zczb_hzd_view t where 1=1 and t.hzd_yh_num=0");
		nyhSql2.append("select t."+type+", count(*) from tb_tj_zczb_xwhzd_view t where 1=1 and t.hzd_yh_num=0");
		
		//未整改隐患企业数
		wyhSql1.append("select t."+type+", count(*) from tb_tj_zczb_hzd_view t where 1=1 and t.hzd_wcl_num>0");
		wyhSql2.append("select t."+type+", count(*) from tb_tj_zczb_xwhzd_view t where 1=1 and t.hzd_wcl_num>0");
		
		if(null==this.cYear || "".equals(this.cYear)){
			this.setCYear(UtilMethod.getZclYear());
		}
		if(null==this.cMonth || "".equals(this.cMonth)){
			this.setCMonth(UtilMethod.getZclMonth());
		}
		
		yingBao1.append(" and ((t.corp_add_time <= to_date('").append(UtilMethod.getZcEdate(Integer.parseInt(this.cYear), Integer.parseInt(this.cMonth))+"','yyyy-MM-dd') and t.is_dele=0) ")
		.append(" or (t.corp_add_time <= to_date('").append(UtilMethod.getZcEdate(Integer.parseInt(this.cYear), Integer.parseInt(this.cMonth))+"','yyyy-MM-dd') and t.update_time >= to_date('")
		.append(UtilMethod.getZcEdate(Integer.parseInt(this.cYear), Integer.parseInt(this.cMonth))+"','yyyy-MM-dd') and t.is_dele=1)) ");
		
		yingBao2.append(" and ((t.corp_add_time <= to_date('").append(UtilMethod.getZcEdate(Integer.parseInt(this.cYear), Integer.parseInt(this.cMonth))+"','yyyy-MM-dd') and t.is_dele=0) ")
		.append(" or (t.corp_add_time <= to_date('").append(UtilMethod.getZcEdate(Integer.parseInt(this.cYear), Integer.parseInt(this.cMonth))+"','yyyy-MM-dd') and t.update_time >= to_date('")
		.append(UtilMethod.getZcEdate(Integer.parseInt(this.cYear), Integer.parseInt(this.cMonth))+"','yyyy-MM-dd') and t.is_dele=1)) ");
		
		yiBao1.append(" and t.hzd_year="+this.cYear+" and t.hzd_month="+this.cMonth);
		yiBao2.append(" and t.hzd_year="+this.cYear+" and t.hzd_month="+this.cMonth);
		yhSql1.append(" and t.hzd_year="+this.cYear+" and t.hzd_month="+this.cMonth);
		yhSql2.append(" and t.hzd_year="+this.cYear+" and t.hzd_month="+this.cMonth);
		nyhSql1.append(" and t.hzd_year="+this.cYear+" and t.hzd_month="+this.cMonth);
		nyhSql2.append(" and t.hzd_year="+this.cYear+" and t.hzd_month="+this.cMonth);
		wyhSql1.append(" and t.hzd_year="+this.cYear+" and t.hzd_month="+this.cMonth);
		wyhSql2.append(" and t.hzd_year="+this.cYear+" and t.hzd_month="+this.cMonth);
		
		if("3".equals(gradeId) && "3".equals(user.getTbUserDept().getDeptClass())){//市科室行业部门
			yingBao1.append(" and t.dept_main_id="+user.getTbUserDept().getId());
			yingBao2.append(" and t.dept_main_id="+user.getTbUserDept().getId());
			yiBao1.append(" and t.dept_main_id="+user.getTbUserDept().getId());
			yiBao2.append(" and t.dept_main_id="+user.getTbUserDept().getId());
			yhSql1.append(" and t.dept_main_id="+user.getTbUserDept().getId());
			yhSql2.append(" and t.dept_main_id="+user.getTbUserDept().getId());
			nyhSql1.append(" and t.dept_main_id="+user.getTbUserDept().getId());
			nyhSql2.append(" and t.dept_main_id="+user.getTbUserDept().getId());
			wyhSql1.append(" and t.dept_main_id="+user.getTbUserDept().getId());
			wyhSql2.append(" and t.dept_main_id="+user.getTbUserDept().getId());
		}else if("4".equals(gradeId) && "3".equals(user.getTbUserDept().getDeptClass())){//县区科室行业部门
			yingBao1.append(" and t.qu_dept_ids like '%"+user.getTbUserDept().getId()+"%' and t.county_id="+user.getTbUserUnit().getId());
			yingBao2.append(" and t.qu_dept_ids like '%"+user.getTbUserDept().getId()+"%' and t.county_id="+user.getTbUserUnit().getId());
			yiBao1.append(" and t.qu_dept_ids like '%"+user.getTbUserDept().getId()+"%' and t.county_id="+user.getTbUserUnit().getId());
			yiBao2.append(" and t.qu_dept_ids like '%"+user.getTbUserDept().getId()+"%' and t.county_id="+user.getTbUserUnit().getId());
			yhSql1.append(" and t.qu_dept_ids like '%"+user.getTbUserDept().getId()+"%' and t.county_id="+user.getTbUserUnit().getId());
			yhSql2.append(" and t.qu_dept_ids like '%"+user.getTbUserDept().getId()+"%' and t.county_id="+user.getTbUserUnit().getId());
			nyhSql1.append(" and t.qu_dept_ids like '%"+user.getTbUserDept().getId()+"%' and t.county_id="+user.getTbUserUnit().getId());
			nyhSql2.append(" and t.qu_dept_ids like '%"+user.getTbUserDept().getId()+"%' and t.county_id="+user.getTbUserUnit().getId());
			wyhSql1.append(" and t.qu_dept_ids like '%"+user.getTbUserDept().getId()+"%' and t.county_id="+user.getTbUserUnit().getId());
			wyhSql2.append(" and t.qu_dept_ids like '%"+user.getTbUserDept().getId()+"%' and t.county_id="+user.getTbUserUnit().getId());
		}else if("5".equals(gradeId)){//市行业
			if("1".equals(user.getTbUserUnit().getDeptClass())){//行业监管
				yingBao1.append(" and t.dept_main_id="+user.getTbUserUnit().getId());
				yingBao2.append(" and t.dept_main_id="+user.getTbUserUnit().getId());
				yiBao1.append(" and t.dept_main_id="+user.getTbUserUnit().getId());
				yiBao2.append(" and t.dept_main_id="+user.getTbUserUnit().getId());
				yhSql1.append(" and t.dept_main_id="+user.getTbUserUnit().getId());
				yhSql2.append(" and t.dept_main_id="+user.getTbUserUnit().getId());
				nyhSql1.append(" and t.dept_main_id="+user.getTbUserUnit().getId());
				nyhSql2.append(" and t.dept_main_id="+user.getTbUserUnit().getId());
				wyhSql1.append(" and t.dept_main_id="+user.getTbUserUnit().getId());
				wyhSql2.append(" and t.dept_main_id="+user.getTbUserUnit().getId());
			}else{//专业监管
				if("5310".equals(user.getTbUserUnit().getId().toString())){//质监局
					yingBao1.append(" and t.corp_is_teshe=1");
					yingBao2.append(" and t.corp_is_teshe=1");
					yiBao1.append(" and t.corp_is_teshe=1");
					yiBao2.append(" and t.corp_is_teshe=1");
					yhSql1.append(" and t.corp_is_teshe=1");
					yhSql2.append(" and t.corp_is_teshe=1");
					nyhSql1.append(" and t.corp_is_teshe=1");
					nyhSql2.append(" and t.corp_is_teshe=1");
					wyhSql1.append(" and t.corp_is_teshe=1");
					wyhSql2.append(" and t.corp_is_teshe=1");
				}else if("5311".equals(user.getTbUserUnit().getId().toString())){//消防局
					
				}else if("5312".equals(user.getTbUserUnit().getId().toString())){//气象局
					yingBao1.append(" and t.corp_is_blzh=1");
					yingBao2.append(" and t.corp_is_blzh=1");
					yiBao1.append(" and t.corp_is_blzh=1");
					yiBao2.append(" and t.corp_is_blzh=1");
					yhSql1.append(" and t.corp_is_blzh=1");
					yhSql2.append(" and t.corp_is_blzh=1");
					nyhSql1.append(" and t.corp_is_blzh=1");
					nyhSql2.append(" and t.corp_is_blzh=1");
					wyhSql1.append(" and t.corp_is_blzh=1");
					wyhSql2.append(" and t.corp_is_blzh=1");
				}
			}
		}else if("6".equals(gradeId)){//县区行业
			if("1".equals(user.getTbUserDept().getDeptClass())){//行业监管
				yingBao1.append(" and t.dept_main_id="+user.getTbUserDept().getDeptSj()+" and t.county_id="+user.getTbUserUnit().getId());
				yingBao2.append(" and t.dept_main_id="+user.getTbUserDept().getDeptSj()+" and t.county_id="+user.getTbUserUnit().getId());
				yiBao1.append(" and t.dept_main_id="+user.getTbUserDept().getDeptSj()+" and t.county_id="+user.getTbUserUnit().getId());
				yiBao2.append(" and t.dept_main_id="+user.getTbUserDept().getDeptSj()+" and t.county_id="+user.getTbUserUnit().getId());
				yhSql1.append(" and t.dept_main_id="+user.getTbUserDept().getDeptSj()+" and t.county_id="+user.getTbUserUnit().getId());
				yhSql2.append(" and t.dept_main_id="+user.getTbUserDept().getDeptSj()+" and t.county_id="+user.getTbUserUnit().getId());
				nyhSql1.append(" and t.dept_main_id="+user.getTbUserDept().getDeptSj()+" and t.county_id="+user.getTbUserUnit().getId());
				nyhSql2.append(" and t.dept_main_id="+user.getTbUserDept().getDeptSj()+" and t.county_id="+user.getTbUserUnit().getId());
				wyhSql1.append(" and t.dept_main_id="+user.getTbUserDept().getDeptSj()+" and t.county_id="+user.getTbUserUnit().getId());
				wyhSql2.append(" and t.dept_main_id="+user.getTbUserDept().getDeptSj()+" and t.county_id="+user.getTbUserUnit().getId());
			}else{
				if("5310".equals(user.getTbUserDept().getDeptSj().toString())){//质监局
					yingBao1.append(" and t.corp_is_teshe=1 and t.county_id="+user.getTbUserUnit().getId());
					yingBao2.append(" and t.corp_is_teshe=1 and t.county_id="+user.getTbUserUnit().getId());
					yiBao1.append(" and t.corp_is_teshe=1 and t.county_id="+user.getTbUserUnit().getId());
					yiBao2.append(" and t.corp_is_teshe=1 and t.county_id="+user.getTbUserUnit().getId());
					yhSql1.append(" and t.corp_is_teshe=1 and t.county_id="+user.getTbUserUnit().getId());
					yhSql2.append(" and t.corp_is_teshe=1 and t.county_id="+user.getTbUserUnit().getId());
					nyhSql1.append(" and t.corp_is_teshe=1 and t.county_id="+user.getTbUserUnit().getId());
					nyhSql2.append(" and t.corp_is_teshe=1 and t.county_id="+user.getTbUserUnit().getId());
					wyhSql1.append(" and t.corp_is_teshe=1 and t.county_id="+user.getTbUserUnit().getId());
					wyhSql2.append(" and t.corp_is_teshe=1 and t.county_id="+user.getTbUserUnit().getId());
				}else if("5311".equals(user.getTbUserDept().getDeptSj().toString())){//消防局
					
				}else if("5312".equals(user.getTbUserDept().getDeptSj().toString())){//气象局
					yingBao1.append(" and t.corp_is_blzh=1 and t.county_id="+user.getTbUserUnit().getId());
					yingBao2.append(" and t.corp_is_blzh=1 and t.county_id="+user.getTbUserUnit().getId());
					yiBao1.append(" and t.corp_is_blzh=1 and t.county_id="+user.getTbUserUnit().getId());
					yiBao2.append(" and t.corp_is_blzh=1 and t.county_id="+user.getTbUserUnit().getId());
					yhSql1.append(" and t.corp_is_blzh=1 and t.county_id="+user.getTbUserUnit().getId());
					yhSql2.append(" and t.corp_is_blzh=1 and t.county_id="+user.getTbUserUnit().getId());
					nyhSql1.append(" and t.corp_is_blzh=1 and t.county_id="+user.getTbUserUnit().getId());
					nyhSql2.append(" and t.corp_is_blzh=1 and t.county_id="+user.getTbUserUnit().getId());
					wyhSql1.append(" and t.corp_is_blzh=1 and t.county_id="+user.getTbUserUnit().getId());
					wyhSql2.append(" and t.corp_is_blzh=1 and t.county_id="+user.getTbUserUnit().getId());
				}
			}
		}else if("7".equals(gradeId)){//乡镇
			yingBao1.append(" and t.county_id="+user.getTbUserUnit().getId()+" and t.unit_id="+user.getTbUserDept().getId());
			yingBao2.append(" and t.county_id="+user.getTbUserUnit().getId()+" and t.unit_id="+user.getTbUserDept().getId());
			yiBao1.append(" and t.county_id="+user.getTbUserUnit().getId()+" and t.unit_id="+user.getTbUserDept().getId());
			yiBao2.append(" and t.county_id="+user.getTbUserUnit().getId()+" and t.unit_id="+user.getTbUserDept().getId());
			yhSql1.append(" and t.county_id="+user.getTbUserUnit().getId()+" and t.unit_id="+user.getTbUserDept().getId());
			yhSql2.append(" and t.county_id="+user.getTbUserUnit().getId()+" and t.unit_id="+user.getTbUserDept().getId());
			nyhSql1.append(" and t.county_id="+user.getTbUserUnit().getId()+" and t.unit_id="+user.getTbUserDept().getId());
			nyhSql2.append(" and t.county_id="+user.getTbUserUnit().getId()+" and t.unit_id="+user.getTbUserDept().getId());
			wyhSql1.append(" and t.county_id="+user.getTbUserUnit().getId()+" and t.unit_id="+user.getTbUserDept().getId());
			wyhSql2.append(" and t.county_id="+user.getTbUserUnit().getId()+" and t.unit_id="+user.getTbUserDept().getId());
		}else if("8".equals(gradeId)){//县区安委会
			yingBao1.append(" and t.county_id="+user.getTbUserUnit().getId());
			yingBao2.append(" and t.county_id="+user.getTbUserUnit().getId());
			yiBao1.append(" and t.county_id="+user.getTbUserUnit().getId());
			yiBao2.append(" and t.county_id="+user.getTbUserUnit().getId());
			yhSql1.append(" and t.county_id="+user.getTbUserUnit().getId());
			yhSql2.append(" and t.county_id="+user.getTbUserUnit().getId());
			nyhSql1.append(" and t.county_id="+user.getTbUserUnit().getId());
			nyhSql2.append(" and t.county_id="+user.getTbUserUnit().getId());
			wyhSql1.append(" and t.county_id="+user.getTbUserUnit().getId());
			wyhSql2.append(" and t.county_id="+user.getTbUserUnit().getId());
		}
		
		if(null!=str && str.length()>0){
			StringBuilder temp = new StringBuilder();
			if("1".equals(str)){//根据区县
				
			}else if("2".equals(str)){//根据企业类型
				
			}else if("3".equals(str)){//根据行业
				
			}else if("4".equals(str)){//根据企业级别
				
			}
			yingBao1.append(" and ").append(temp);
			yingBao2.append(" and ").append(temp);
			yiBao1.append(" and ").append(temp);
			yiBao2.append(" and ").append(temp);
			yhSql1.append(" and ").append(temp);
			yhSql2.append(" and ").append(temp);
			nyhSql1.append(" and ").append(temp);
			nyhSql2.append(" and ").append(temp);
			wyhSql1.append(" and ").append(temp);
			wyhSql2.append(" and ").append(temp);
		}
		yingBao1.append(" group by t."+type);
		yingBao2.append(" group by t."+type);
		yiBao1.append(" group by t."+type);
		yiBao2.append(" group by t."+type);
		yhSql1.append(" group by t."+type);
		yhSql2.append(" group by t."+type);
		nyhSql1.append(" group by t."+type);
		nyhSql2.append(" group by t."+type);
		wyhSql1.append(" group by t."+type);
		wyhSql2.append(" group by t."+type);
		
		if(logger.isDebugEnabled()) {
			logger.debug("yingBao1 ---> " + yingBao1);
			logger.debug("yiBao1 ---> " + yiBao1);
		}
	}
	
	/**
	 * 封装统计sql 隐患数统计
	 * @param type 按照什么去分组 如区县，乡镇，企业类型，企业级别等
	 * @param str 查询条件是什么 如按照属地统计，只统计东营区乡镇的上报情况，或者按照企业类型，统计危险化学品类下各区县的上报情况
	 */
	public void initYhSql(String type,String str){
		TbUser user = (TbUser) this.contextPvd.getSessionAttr(Util.SESSION_ADMINUSER);
		String  gradeId = user.getTbUserGrade().getId().toString();
		
		//一般隐患数
		ybYhSql1.append("select t."+type+", sum(t.hzd_same_num) from tb_tj_zczb_hzd_view t where t."+type+">0 ");//一般隐患数
		ybYhSql2.append("select t."+type+", sum(t.hzd_same_cl) from tb_tj_zczb_hzd_view t where t."+type+">0 ");//一般隐患整改数
		
		//重大隐患数
		bigYhSql1.append("select t."+type+", sum(t.hzd_big_num) from tb_tj_zczb_hzd_view t where t."+type+">0 ");//隐患数
		bigYhSql2.append("select t."+type+", sum(t.hzd_big_cl) from tb_tj_zczb_hzd_view t where t."+type+">0 ");//整改数
		
		if(null==this.cYear || "".equals(this.cYear)){
			this.setCYear(UtilMethod.getZclYear());
		}
		if(null==this.cMonth || "".equals(this.cMonth)){
			this.setCMonth(UtilMethod.getZclMonth());
		}
		
		ybYhSql1.append(" and t.hzd_year="+this.cYear+" and t.hzd_month="+this.cMonth);
		ybYhSql2.append(" and t.hzd_year="+this.cYear+" and t.hzd_month="+this.cMonth);
		bigYhSql1.append(" and t.hzd_year="+this.cYear+" and t.hzd_month="+this.cMonth);
		bigYhSql2.append(" and t.hzd_year="+this.cYear+" and t.hzd_month="+this.cMonth);
		
		if("3".equals(gradeId) && "3".equals(user.getTbUserDept().getDeptClass())){//市科室行业部门
			ybYhSql1.append(" and t.dept_main_id="+user.getTbUserDept().getId());
			ybYhSql2.append(" and t.dept_main_id="+user.getTbUserDept().getId());
			bigYhSql1.append(" and t.dept_main_id="+user.getTbUserDept().getId());
			bigYhSql2.append(" and t.dept_main_id="+user.getTbUserDept().getId());
		}else if("4".equals(gradeId) && "3".equals(user.getTbUserDept().getDeptClass())){//县区科室行业部门
			ybYhSql1.append(" and t.qu_dept_ids="+user.getTbUserDept().getId()+" and t.county_id="+user.getTbUserUnit().getId());
			ybYhSql2.append(" and t.qu_dept_ids="+user.getTbUserDept().getId()+" and t.county_id="+user.getTbUserUnit().getId());
			bigYhSql1.append(" and t.qu_dept_ids="+user.getTbUserDept().getId()+" and t.county_id="+user.getTbUserUnit().getId());
			bigYhSql2.append(" and t.qu_dept_ids="+user.getTbUserDept().getId()+" and t.county_id="+user.getTbUserUnit().getId());
		}else if("5".equals(gradeId)){//市行业
			if("1".equals(user.getTbUserUnit().getDeptClass())){//行业监管
				ybYhSql1.append(" and t.dept_main_id="+user.getTbUserUnit().getId());
				ybYhSql2.append(" and t.dept_main_id="+user.getTbUserUnit().getId());
				bigYhSql1.append(" and t.dept_main_id="+user.getTbUserUnit().getId());
				bigYhSql2.append(" and t.dept_main_id="+user.getTbUserUnit().getId());
			}else{//专业监管
				if("5310".equals(user.getTbUserUnit().getId().toString())){//质监局
					ybYhSql1.append(" and t.corp_is_teshe=1");
					ybYhSql2.append(" and t.corp_is_teshe=1");
					bigYhSql1.append(" and t.corp_is_teshe=1");
					bigYhSql2.append(" and t.corp_is_teshe=1");
				}else if("5311".equals(user.getTbUserUnit().getId().toString())){//消防局
					
				}else if("5312".equals(user.getTbUserUnit().getId().toString())){//气象局
					ybYhSql1.append(" and t.corp_is_blzh=1");
					ybYhSql2.append(" and t.corp_is_blzh=1");
					bigYhSql1.append(" and t.corp_is_blzh=1");
					bigYhSql2.append(" and t.corp_is_blzh=1");
				}
			}
		}else if("6".equals(gradeId)){//县区行业
			if("1".equals(user.getTbUserDept().getDeptClass())){//行业监管
				ybYhSql1.append(" and t.dept_main_id="+user.getTbUserDept().getDeptSj()+" and t.county_id="+user.getTbUserUnit().getId());
				ybYhSql2.append(" and t.dept_main_id="+user.getTbUserDept().getDeptSj()+" and t.county_id="+user.getTbUserUnit().getId());
				bigYhSql1.append(" and t.dept_main_id="+user.getTbUserDept().getDeptSj()+" and t.county_id="+user.getTbUserUnit().getId());
				bigYhSql2.append(" and t.dept_main_id="+user.getTbUserDept().getDeptSj()+" and t.county_id="+user.getTbUserUnit().getId());
			}else{
				if("5310".equals(user.getTbUserDept().getDeptSj().toString())){//质监局
					ybYhSql1.append(" and t.corp_is_teshe=1 and t.county_id="+user.getTbUserUnit().getId());
					ybYhSql2.append(" and t.corp_is_teshe=1 and t.county_id="+user.getTbUserUnit().getId());
					bigYhSql1.append(" and t.corp_is_teshe=1 and t.county_id="+user.getTbUserUnit().getId());
					bigYhSql2.append(" and t.corp_is_teshe=1 and t.county_id="+user.getTbUserUnit().getId());
				}else if("5311".equals(user.getTbUserDept().getDeptSj().toString())){//消防局
					
				}else if("5312".equals(user.getTbUserDept().getDeptSj().toString())){//气象局
					ybYhSql1.append(" and t.corp_is_blzh=1 and t.county_id="+user.getTbUserUnit().getId());
					ybYhSql2.append(" and t.corp_is_blzh=1 and t.county_id="+user.getTbUserUnit().getId());
					bigYhSql1.append(" and t.corp_is_blzh=1 and t.county_id="+user.getTbUserUnit().getId());
					bigYhSql2.append(" and t.corp_is_blzh=1 and t.county_id="+user.getTbUserUnit().getId());
				}
			}
		}else if("7".equals(gradeId)){//乡镇
			ybYhSql1.append(" and t.county_id="+user.getTbUserUnit().getId()+" and t.unit_id="+user.getTbUserDept().getId());
			ybYhSql2.append(" and t.county_id="+user.getTbUserUnit().getId()+" and t.unit_id="+user.getTbUserDept().getId());
			bigYhSql1.append(" and t.county_id="+user.getTbUserUnit().getId()+" and t.unit_id="+user.getTbUserDept().getId());
			bigYhSql2.append(" and t.county_id="+user.getTbUserUnit().getId()+" and t.unit_id="+user.getTbUserDept().getId());
		}else if("8".equals(gradeId)){//县区安委会
			ybYhSql1.append(" and t.county_id="+user.getTbUserUnit().getId());
			ybYhSql2.append(" and t.county_id="+user.getTbUserUnit().getId());
			bigYhSql1.append(" and t.county_id="+user.getTbUserUnit().getId());
			bigYhSql2.append(" and t.county_id="+user.getTbUserUnit().getId());
		}
		
		if(null!=str && str.length()>0){
			StringBuilder temp = new StringBuilder();
			if("1".equals(str)){//根据区县
				
			}else if("2".equals(str)){//根据企业类型
				
			}else if("3".equals(str)){//根据行业
				
			}else if("4".equals(str)){//根据企业级别
				
			}
			ybYhSql1.append(" and ").append(temp);
			ybYhSql2.append(" and ").append(temp);
			bigYhSql1.append(" and ").append(temp);
			bigYhSql2.append(" and ").append(temp);
		}
		ybYhSql1.append(" group by t."+type);
		ybYhSql2.append(" group by t."+type);
		bigYhSql1.append(" group by t."+type);
		bigYhSql2.append(" group by t."+type);
	}
	
	/**
	 * 按时间 年/月 对隐患总数进行统计 
	 * @param type
	 * @param str
	 */
	public void yhStaticSql(){
		TbUser user = (TbUser) this.contextPvd.getSessionAttr(Util.SESSION_ADMINUSER);
		String  gradeId = user.getTbUserGrade().getId().toString();
		
		//一般隐患数
		ybYhSql1.append("select t.hzd_year|| '年/' || t.hzd_month||'月', sum(t.hzd_same_num) from tb_tj_zczb_hzd_view t where t.hzd_year>0 ");//一般隐患数
		ybYhSql2.append("select t.hzd_year|| '年/' || t.hzd_month||'月', sum(t.hzd_same_cl) from tb_tj_zczb_hzd_view t where t.hzd_year>0 ");//一般隐患整改数
		
		//重大隐患数
		bigYhSql1.append("select t.hzd_year|| '年/' || t.hzd_month||'月', sum(t.hzd_big_num) from tb_tj_zczb_hzd_view t where t.hzd_year>0 ");//隐患数
		bigYhSql2.append("select t.hzd_year|| '年/' || t.hzd_month||'月', sum(t.hzd_big_cl) from tb_tj_zczb_hzd_view t where t.hzd_year>0 ");//整改数
		
		/*if(null==this.cYear || "".equals(this.cYear)){
			this.setCYear(UtilMethod.getZclYear());
		}
		if(null==this.cMonth || "".equals(this.cMonth)){
			this.setCMonth(UtilMethod.getZclMonth());
		}*/
		
		//ybYhSql1.append(" and t.hzd_year="+this.cYear+" and t.hzd_month="+this.cMonth);
		//ybYhSql2.append(" and t.hzd_year="+this.cYear+" and t.hzd_month="+this.cMonth);
		//bigYhSql1.append(" and t.hzd_year="+this.cYear+" and t.hzd_month="+this.cMonth);
		//bigYhSql2.append(" and t.hzd_year="+this.cYear+" and t.hzd_month="+this.cMonth);
		
		if("3".equals(gradeId) && "3".equals(user.getTbUserDept().getDeptClass())){//市科室行业部门
			ybYhSql1.append(" and t.dept_main_id="+user.getTbUserDept().getId());
			ybYhSql2.append(" and t.dept_main_id="+user.getTbUserDept().getId());
			bigYhSql1.append(" and t.dept_main_id="+user.getTbUserDept().getId());
			bigYhSql2.append(" and t.dept_main_id="+user.getTbUserDept().getId());
		}else if("4".equals(gradeId) && "3".equals(user.getTbUserDept().getDeptClass())){//县区科室行业部门
			ybYhSql1.append(" and t.qu_dept_ids="+user.getTbUserDept().getId()+" and t.county_id="+user.getTbUserUnit().getId());
			ybYhSql2.append(" and t.qu_dept_ids="+user.getTbUserDept().getId()+" and t.county_id="+user.getTbUserUnit().getId());
			bigYhSql1.append(" and t.qu_dept_ids="+user.getTbUserDept().getId()+" and t.county_id="+user.getTbUserUnit().getId());
			bigYhSql2.append(" and t.qu_dept_ids="+user.getTbUserDept().getId()+" and t.county_id="+user.getTbUserUnit().getId());
		}else if("5".equals(gradeId)){//市行业
			if("1".equals(user.getTbUserUnit().getDeptClass())){//行业监管
				ybYhSql1.append(" and t.dept_main_id="+user.getTbUserUnit().getId());
				ybYhSql2.append(" and t.dept_main_id="+user.getTbUserUnit().getId());
				bigYhSql1.append(" and t.dept_main_id="+user.getTbUserUnit().getId());
				bigYhSql2.append(" and t.dept_main_id="+user.getTbUserUnit().getId());
			}else{//专业监管
				if("5310".equals(user.getTbUserUnit().getId().toString())){//质监局
					ybYhSql1.append(" and t.corp_is_teshe=1");
					ybYhSql2.append(" and t.corp_is_teshe=1");
					bigYhSql1.append(" and t.corp_is_teshe=1");
					bigYhSql2.append(" and t.corp_is_teshe=1");
				}else if("5311".equals(user.getTbUserUnit().getId().toString())){//消防局
					
				}else if("5312".equals(user.getTbUserUnit().getId().toString())){//气象局
					ybYhSql1.append(" and t.corp_is_blzh=1");
					ybYhSql2.append(" and t.corp_is_blzh=1");
					bigYhSql1.append(" and t.corp_is_blzh=1");
					bigYhSql2.append(" and t.corp_is_blzh=1");
				}
			}
		}else if("6".equals(gradeId)){//县区行业
			if("1".equals(user.getTbUserDept().getDeptClass())){//行业监管
				ybYhSql1.append(" and t.dept_main_id="+user.getTbUserDept().getDeptSj()+" and t.county_id="+user.getTbUserUnit().getId());
				ybYhSql2.append(" and t.dept_main_id="+user.getTbUserDept().getDeptSj()+" and t.county_id="+user.getTbUserUnit().getId());
				bigYhSql1.append(" and t.dept_main_id="+user.getTbUserDept().getDeptSj()+" and t.county_id="+user.getTbUserUnit().getId());
				bigYhSql2.append(" and t.dept_main_id="+user.getTbUserDept().getDeptSj()+" and t.county_id="+user.getTbUserUnit().getId());
			}else{
				if("5310".equals(user.getTbUserDept().getDeptSj().toString())){//质监局
					ybYhSql1.append(" and t.corp_is_teshe=1 and t.county_id="+user.getTbUserUnit().getId());
					ybYhSql2.append(" and t.corp_is_teshe=1 and t.county_id="+user.getTbUserUnit().getId());
					bigYhSql1.append(" and t.corp_is_teshe=1 and t.county_id="+user.getTbUserUnit().getId());
					bigYhSql2.append(" and t.corp_is_teshe=1 and t.county_id="+user.getTbUserUnit().getId());
				}else if("5311".equals(user.getTbUserDept().getDeptSj().toString())){//消防局
					
				}else if("5312".equals(user.getTbUserDept().getDeptSj().toString())){//气象局
					ybYhSql1.append(" and t.corp_is_blzh=1 and t.county_id="+user.getTbUserUnit().getId());
					ybYhSql2.append(" and t.corp_is_blzh=1 and t.county_id="+user.getTbUserUnit().getId());
					bigYhSql1.append(" and t.corp_is_blzh=1 and t.county_id="+user.getTbUserUnit().getId());
					bigYhSql2.append(" and t.corp_is_blzh=1 and t.county_id="+user.getTbUserUnit().getId());
				}
			}
		}else if("7".equals(gradeId)){//乡镇
			ybYhSql1.append(" and t.county_id="+user.getTbUserUnit().getId()+" and t.unit_id="+user.getTbUserDept().getId());
			ybYhSql2.append(" and t.county_id="+user.getTbUserUnit().getId()+" and t.unit_id="+user.getTbUserDept().getId());
			bigYhSql1.append(" and t.county_id="+user.getTbUserUnit().getId()+" and t.unit_id="+user.getTbUserDept().getId());
			bigYhSql2.append(" and t.county_id="+user.getTbUserUnit().getId()+" and t.unit_id="+user.getTbUserDept().getId());
		}else if("8".equals(gradeId)){//县区安委会
			ybYhSql1.append(" and t.county_id="+user.getTbUserUnit().getId());
			ybYhSql2.append(" and t.county_id="+user.getTbUserUnit().getId());
			bigYhSql1.append(" and t.county_id="+user.getTbUserUnit().getId());
			bigYhSql2.append(" and t.county_id="+user.getTbUserUnit().getId());
		}
		
	/*	if(null!=str && str.length()>0){
			StringBuilder temp = new StringBuilder();
			if("1".equals(str)){//根据区县
				
			}else if("2".equals(str)){//根据企业类型
				
			}else if("3".equals(str)){//根据行业
				
			}else if("4".equals(str)){//根据企业级别
				
			}
			ybYhSql1.append(" and ").append(temp);
			ybYhSql2.append(" and ").append(temp);
			bigYhSql1.append(" and ").append(temp);
			bigYhSql2.append(" and ").append(temp);
		}*/
		ybYhSql1.append(" group by t.hzd_year||'年/' || t.hzd_month||'月' order by t.hzd_year|| '年/' || t.hzd_month||'月' desc");
		ybYhSql2.append(" group by t.hzd_year||'年/' || t.hzd_month||'月' order by t.hzd_year|| '年/' || t.hzd_month||'月' desc");
		bigYhSql1.append(" group by t.hzd_year||'年/' || t.hzd_month||'月' order by t.hzd_year|| '年/' || t.hzd_month||'月' desc");
		bigYhSql2.append(" group by t.hzd_year||'年/' || t.hzd_month||'月' order by t.hzd_year|| '年/' || t.hzd_month||'月' desc");
	}
	
	/**
	 * 循环查询数据并放到htmlList中
	 * @param selSql 类型sql 如县区部门、乡镇、行业、企业类型、企业级别
	 * @param yingBao1
	 * @param yingBao2
	 * @param yiBao1
	 * @param yiBao2
	 * @param yhSql1
	 * @param yhSql2
	 * @param nyhSql1
	 * @param nyhSql2
	 * @param wyhSql1
	 * @param wyhSql2
	 */
	public void resultZczb(String selSql,String yingBao1,String yingBao2,String yiBao1,String yiBao2,
			String yhSql1,String yhSql2,String nyhSql1,String nyhSql2,String wyhSql1,String wyhSql2){
		try {
			List list = this.utilService.getObjectBySql(selSql, 0, 0);
			List list1 = this.utilService.getObjectBySql(yingBao1, 0, 0);
			List list2 = this.utilService.getObjectBySql(yingBao2, 0, 0);
			List list3 = this.utilService.getObjectBySql(yiBao1, 0, 0);
			List list4 = this.utilService.getObjectBySql(yiBao2, 0, 0);
			List list5 = this.utilService.getObjectBySql(yhSql1, 0, 0);
			List list6 = this.utilService.getObjectBySql(yhSql2, 0, 0);
			List list7 = this.utilService.getObjectBySql(nyhSql1, 0, 0);
			List list8 = this.utilService.getObjectBySql(nyhSql2, 0, 0);
			List list9 = this.utilService.getObjectBySql(wyhSql1, 0, 0);
			List list10 = this.utilService.getObjectBySql(wyhSql2, 0, 0);
			List htmlList = new ArrayList();
			DecimalFormat df = new DecimalFormat("0.00");
			StringBuffer strXml = new StringBuffer();
			if(null!=list && list.size()>0){
				Object[] obj4 = new Object[] {null,null,"总计",0,0,"0.00%",0,"0.00%",0,"0.00%",0};
				for(int i=0;i<list.size();i++){
//					Map<Object[],List> map = new LinkedHashMap<Object[], List>();
					Object sel[] = (Object[]) list.get(i);
					Object[] obj1 = new Object[] {sel[0],sel[1],"规模以上",0,0,"0.00%",0,"0.00%",0,"0.00%",0};
					Object[] obj2 = new Object[] {sel[0],sel[1],"小微企业",0,0,"0.00%",0,"0.00%",0,"0.00%",0};
					Object[] obj3 = new Object[] {sel[0],sel[1],"小计",0,0,"0.00%",0,"0.00%",0,"0.00%",0};
					for(int j=0;j<list1.size();j++){
						Object resultObj[] = (Object[])list1.get(j) ;
						if(null!=resultObj[0] && sel[0].toString().equals(resultObj[0].toString()) ){
							obj1[3]=resultObj[1];
							obj3[3]=resultObj[1];
							break ;
						}
					}
					for(int j=0;j<list2.size();j++){
						Object resultObj[] = (Object[])list2.get(j) ;
						if(null!=resultObj[0] && sel[0].toString().equals(resultObj[0].toString()) ){
							obj2[3]=resultObj[1];
							obj3[3]=Integer.parseInt(obj3[3].toString())+Integer.parseInt(resultObj[1].toString());
							break ;
						}
					}
					obj4[3]=Integer.parseInt(obj4[3].toString())+Integer.parseInt(obj3[3].toString());
					for(int j=0;j<list3.size();j++){
						Object resultObj[] = (Object[])list3.get(j) ;
						if(null!=resultObj[0] && sel[0].toString().equals(resultObj[0].toString()) ){
							obj1[4]=resultObj[1];
							obj3[4]=resultObj[1];
							break ;
						}
					}
					for(int j=0;j<list4.size();j++){
						Object resultObj[] = (Object[])list4.get(j) ;
						if(null!=resultObj[0] && sel[0].toString().equals(resultObj[0].toString()) ){
							obj2[4]=resultObj[1];
							obj3[4]=Integer.parseInt(obj3[4].toString())+Integer.parseInt(resultObj[1].toString());
							break ;
						}
					}
					obj4[4]=Integer.parseInt(obj4[4].toString())+Integer.parseInt(obj3[4].toString());
					for(int j=0;j<list5.size();j++){
						Object resultObj[] = (Object[])list5.get(j) ;
						if(null!=resultObj[0] && sel[0].toString().equals(resultObj[0].toString()) ){
							obj1[6]=resultObj[1];
							obj3[6]=resultObj[1];
							break ;
						}
					}
					for(int j=0;j<list6.size();j++){
						Object resultObj[] = (Object[])list6.get(j) ;
						if(null!=resultObj[0] && sel[0].toString().equals(resultObj[0].toString()) ){
							obj3[6]=resultObj[1];
							obj3[6]=Integer.parseInt(obj3[6].toString())+Integer.parseInt(resultObj[1].toString());
							break ;
						}
					}
					obj4[6]=Integer.parseInt(obj4[6].toString())+Integer.parseInt(obj3[6].toString());
					for(int j=0;j<list7.size();j++){
						Object resultObj[] = (Object[])list7.get(j) ;
						if(null!=resultObj[0] && sel[0].toString().equals(resultObj[0].toString()) ){
							obj1[8]=resultObj[1];
							obj3[8]=resultObj[1];
							break ;
						}
					}
					for(int j=0;j<list8.size();j++){
						Object resultObj[] = (Object[])list8.get(j) ;
						if(null!=resultObj[0] && sel[0].toString().equals(resultObj[0].toString()) ){
							obj2[8]=resultObj[1];
							obj3[8]=Integer.parseInt(obj3[8].toString())+Integer.parseInt(resultObj[1].toString());
							break ;
						}
					}
					obj4[8]=Integer.parseInt(obj4[8].toString())+Integer.parseInt(obj3[8].toString());
					for(int j=0;j<list9.size();j++){
						Object resultObj[] = (Object[])list9.get(j) ;
						if(null!=resultObj[0] && sel[0].toString().equals(resultObj[0].toString()) ){
							obj1[10]=resultObj[1];
							obj3[10]=resultObj[1];
							break ;
						}
					}
					for(int j=0;j<list10.size();j++){
						Object resultObj[] = (Object[])list10.get(j) ;
						if(null!=resultObj[0] && sel[0].toString().equals(resultObj[0].toString()) ){
							obj2[10]=resultObj[1];
							obj3[10]=Integer.parseInt(obj3[10].toString())+Integer.parseInt(resultObj[1].toString());
							break ;
						}
					}
					obj4[10]=Integer.parseInt(obj4[10].toString())+Integer.parseInt(obj3[10].toString());
					Double obj1_yb = Double.parseDouble(obj1[3].toString());//应报
					Double obj1_yib = Double.parseDouble(obj1[4].toString());//已报
					if(obj1_yb != 0.00){//应报企业数不为0
						Double cnum = obj1_yib/obj1_yb *100;
						obj1[5] = df.format(cnum)+"%" ; //企业上报率 规模企业
					}
					Double obj2_yb = Double.parseDouble(obj2[3].toString());//应报
					Double obj2_yib = Double.parseDouble(obj2[4].toString());//已报
					if(obj2_yb != 0.00){//应报企业数不为0
						Double cnum = obj2_yib/obj2_yb *100;
						obj2[5] = df.format(cnum)+"%" ; //企业上报率  小微企业
					}
					Double obj3_yb = Double.parseDouble(obj3[3].toString());//应报
					Double obj3_yib = Double.parseDouble(obj3[4].toString());//已报
					if(obj3_yb != 0.00){//应报企业数不为0
						Double cnum = obj3_yib/obj3_yb *100;
						obj3[5] = df.format(cnum)+"%" ; //企业上报率  小计
					}
					
					Double obj1_wyh = Double.parseDouble(obj1[8].toString());//无隐患企业
					if(obj1_yib != 0.00){//应报企业数不为0
						Double cnum = (obj1_yib-obj1_wyh)/obj1_yib *100;
						obj1[7] = df.format(cnum)+"%" ; //企业上报率 规模企业
						
						cnum = (obj1_yib-obj1_wyh)/obj1_yb *100;
						obj1[9] = df.format(cnum)+"%" ;
					}
					Double obj2_wyh = Double.parseDouble(obj2[8].toString());//无隐患企业
					if(obj2_yib != 0.00){//应报企业数不为0
						Double cnum = (obj2_yib-obj2_wyh)/obj2_yib *100;
						obj2[7] = df.format(cnum)+"%" ; //企业上报率  小微企业
						
						cnum = (obj2_yib-obj2_wyh)/obj2_yb *100;
						obj2[9] = df.format(cnum)+"%" ;
					}
					Double obj3_wyh = Double.parseDouble(obj3[8].toString());//无隐患企业
					if(obj3_yib != 0.00){//应报企业数不为0
						Double cnum = (obj3_yib-obj3_wyh)/obj3_yib *100;
						obj3[7] = df.format(cnum)+"%" ; //企业上报率  小计
						
						cnum = (obj3_yib-obj3_wyh)/obj3_yb *100;
						obj3[9] = df.format(cnum)+"%" ;
					}
					
					
					
					
					strXml.append("<set name='" + obj3[1] + "' value='" + obj3[4] + "'/>");
					htmlList.add(obj1);
					htmlList.add(obj2);
					htmlList.add(obj3);
				}
				
				
				//the last line for table
				Double obj4_yb = Double.parseDouble(obj4[3].toString());//应报
				Double obj4_yib = Double.parseDouble(obj4[4].toString());//已报
				if(obj4_yb != 0.00){//应报企业数不为0
					Double cnum = obj4_yib/obj4_yb *100;
					obj4[5] = df.format(cnum)+"%" ; //企业上报率  小计
				}
				Double obj4_wyh = Double.parseDouble(obj4[8].toString());//无隐患企业
				if(obj4_yib != 0.00){//应报企业数不为0
					Double cnum = (obj4_yib-obj4_wyh)/obj4_yib *100;
					obj4[7] = df.format(cnum)+"%" ; //企业上报率  小计
				}
				
				htmlList.add(obj4);
				this.setHtmlList(htmlList);
				this.setXmlString(strXml.toString());
				
				if (exportExcelFlag != null && exportExcelFlag.equals("1")) {
					Workbook wb = new HSSFWorkbook();
					CreationHelper createHelper = wb.getCreationHelper();
					Sheet sheet = wb.createSheet(tjName);
					
					for(int i=0; i < 11; i ++) {
						sheet.autoSizeColumn(i);
					}
				    Row row = sheet.createRow((short)0);
				    row.setHeightInPoints(20);
				    setMergeCell(sheet, 0,0,0,9);
				    //
				    createCell(wb, row, (short) 0, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, "企业上报数据统计---"+tjName);

				    Row title1 = sheet.createRow((short)1);
				    setMergeCell(sheet, 1,1,0,1);
				    createCell(wb, title1, (short) 0, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, titleName);
					createCell(wb, title1, (short) 2, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, "应报企业数");
					createCell(wb, title1, (short) 3, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, "已报企业数");
					createCell(wb, title1, (short) 4, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, "企业上报率");
					createCell(wb, title1, (short) 5, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, "（已报隐患）企业数");
					createCell(wb, title1, (short) 6, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, "（已报隐患）企业上报率");
					createCell(wb, title1, (short) 7, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, "无隐患企业数");
					createCell(wb, title1, (short) 8, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, "隐患企业比例");
					createCell(wb, title1, (short) 9, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, "未整改隐患企业数");
					
					//set first column 
					for(int i = 0; i < htmlList.size(); i ++) {
						//Object[] obj = (Object[])htmlList.get(i);
						 sheet.createRow((short) i+2);
					}
					
					for(int i = 0; i < htmlList.size(); i ++) {
						Object[] obj = (Object[])htmlList.get(i);
						Row dataRow = sheet.getRow(i+2);
						//每隔三行合并单元格
						if((i+1) % 3 == 1) {
							setMergeCell(sheet, i+1,i+3,0,0);
						}
						for(int j = 1; j < 11; j ++ ) {
							if(logger.isDebugEnabled()) {
								logger.debug("obj info j = " +j + ", obj[j]" + obj[j]  );
							}
							if(obj[j] != null) {
								if(j == 9) {
									createCell(wb, dataRow, (short) (j-1), CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, obj[7].toString());
								} else if(j==6){
									int yibao = Integer.parseInt(obj[4].toString()); 
									int noyh = Integer.parseInt(obj[8].toString()); 
									createCell(wb, dataRow, (short) (j-1), CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, String.valueOf(yibao - noyh));
								} else {
									createCell(wb, dataRow, (short) (j-1), CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, obj[j].toString());
								}
							}
							
						}
					}
					HttpServletResponse response = this.contextPvd.getResponse();
					response.reset();
					
					response.setContentType("application/x-msdownload");
					response.addHeader("Content-Disposition","attachment; filename=\"" +java.net.URLEncoder.encode("上报隐患数据统计---"+tjName, "UTF-8")+".xls\"");
					ByteArrayOutputStream ostream = new ByteArrayOutputStream();
					ServletOutputStream servletOS = response.getOutputStream();
					wb.write(ostream);
					servletOS.write(ostream.toByteArray());
					servletOS.flush();
					servletOS.close();
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
			Loggers.error("TjZczbAction resultZczb（）异常 "+e.getMessage());
		}
	}
	
	/**
	 * 循环查询数据并放到htmlList中
	 * @param selSql 类型sql 如县区部门、乡镇、行业、企业类型、企业级别
	 * @param ybYhSql1 一般隐患数
	 * @param ybYhSql2 一般隐患整改数
	 * @param bigYhSql1 重大隐患数
	 * @param bigYhSql2 重大隐患整改数
	 */
	public void resultYh(String selSql,String ybYhSql1,String ybYhSql2,String bigYhSql1,String bigYhSql2){
		try {
			List list = this.utilService.getObjectBySql(selSql, 0, 0);
			List list1 = this.utilService.getObjectBySql(ybYhSql1, 0, 0);
			List list2 = this.utilService.getObjectBySql(ybYhSql2, 0, 0);
			List list3 = this.utilService.getObjectBySql(bigYhSql1, 0, 0);
			List list4 = this.utilService.getObjectBySql(bigYhSql2, 0, 0);
			List htmlList = new ArrayList();
			DecimalFormat df = new DecimalFormat("0.00");
			StringBuffer strXml = new StringBuffer();
			Object[] obj3 = new Object[] {"0","总计",0,0,"0.00%",0,0,"0.00%",0,0,"0.00%"};
			if(null!=list && list.size()>0){
				for(int i=0;i<list.size();i++){
					Object sel[] = (Object[]) list.get(i);
					Object[] obj1 = new Object[] {sel[0],sel[1],0,0,"0.00%",0,0,"0.00%",0,0,"0.00%"};
					for(int j=0;j<list1.size();j++){
						Object resultObj[] = (Object[])list1.get(j) ;
						if(null!=resultObj[0] && sel[0].toString().equals(resultObj[0].toString()) ){
							obj1[2]=resultObj[1];
							obj3[2]=Integer.parseInt(obj3[2].toString())+Integer.parseInt(resultObj[1].toString());
							break ;
						}
					}
					for(int j=0;j<list2.size();j++){
						Object resultObj[] = (Object[])list2.get(j) ;
						if(null!=resultObj[0] && sel[0].toString().equals(resultObj[0].toString()) ){
							obj1[3]=resultObj[1];
							obj3[3]=Integer.parseInt(obj3[3].toString())+Integer.parseInt(resultObj[1].toString());
							break ;
						}
					}
					for(int j=0;j<list3.size();j++){
						Object resultObj[] = (Object[])list3.get(j) ;
						if(null!=resultObj[0] && sel[0].toString().equals(resultObj[0].toString()) ){
							obj1[5]=resultObj[1];
							obj3[5]=Integer.parseInt(obj3[5].toString())+Integer.parseInt(resultObj[1].toString());
							break ;
						}
					}
					for(int j=0;j<list4.size();j++){
						Object resultObj[] = (Object[])list4.get(j) ;
						if(null!=resultObj[0] && sel[0].toString().equals(resultObj[0].toString()) ){
							obj1[6]=resultObj[1];
							obj3[6]=Integer.parseInt(obj3[6].toString())+Integer.parseInt(resultObj[1].toString());
							break ;
						}
					}
					obj1[8] = Integer.parseInt(obj1[2].toString())+Integer.parseInt(obj1[5].toString());
					obj1[9] = Integer.parseInt(obj1[3].toString())+Integer.parseInt(obj1[6].toString());
					obj3[8] = Integer.parseInt(obj3[8].toString())+Integer.parseInt(obj1[8].toString());
					obj3[9] = Integer.parseInt(obj3[9].toString())+Integer.parseInt(obj1[9].toString());
					Double obj1_yb = Double.parseDouble(obj1[2].toString());//隐患数
					Double obj1_yib = Double.parseDouble(obj1[3].toString());//整改数
					if(obj1_yb != 0.00){//隐患数不为0
						Double cnum = obj1_yib/obj1_yb *100;
						obj1[4] = df.format(cnum)+"%" ; //隐患整改率
					}
					Double obj2_yb = Double.parseDouble(obj1[5].toString());//隐患数
					Double obj2_yib = Double.parseDouble(obj1[6].toString());//整改数
					if(obj2_yb != 0.00){//隐患数不为0
						Double cnum = obj2_yib/obj2_yb *100;
						obj1[7] = df.format(cnum)+"%" ; //隐患整改率
					}
					Double obj3_yb = Double.parseDouble(obj1[8].toString());//隐患数
					Double obj3_yib = Double.parseDouble(obj1[9].toString());//整改数
					if(obj3_yb != 0.00){//隐患数不为0
						Double cnum = obj3_yib/obj3_yb *100;
						obj1[10] = df.format(cnum)+"%" ; //隐患整改率
					}
					strXml.append("<set name='" + obj1[1] + "' value='" + obj1[8] + "'/>");
					htmlList.add(obj1);
					
				}
				Double obj1_yb = Double.parseDouble(obj3[2].toString());//隐患数
				Double obj1_yib = Double.parseDouble(obj3[3].toString());//整改数
				if(obj1_yb != 0.00){//隐患数不为0
					Double cnum = obj1_yib/obj1_yb *100;
					obj3[4] = df.format(cnum)+"%" ; //隐患整改率
				}
				Double obj2_yb = Double.parseDouble(obj3[5].toString());//隐患数
				Double obj2_yib = Double.parseDouble(obj3[6].toString());//整改数
				if(obj2_yb != 0.00){//隐患数不为0
					Double cnum = obj2_yib/obj2_yb *100;
					obj3[7] = df.format(cnum)+"%" ; //隐患整改率
				}
				Double obj3_yb = Double.parseDouble(obj3[8].toString());//隐患数
				Double obj3_yib = Double.parseDouble(obj3[9].toString());//整改数
				if(obj3_yb != 0.00){//隐患数不为0
					Double cnum = obj3_yib/obj3_yb *100;
					obj3[10] = df.format(cnum)+"%" ; //隐患整改率
				}
				htmlList.add(obj3);
				this.setHtmlList(htmlList);
				this.setXmlString(strXml.toString());
				
				if (exportExcelFlag != null && exportExcelFlag.equals("1")) {
					Workbook wb = new HSSFWorkbook();
					CreationHelper createHelper = wb.getCreationHelper();
					Sheet sheet = wb.createSheet(tjName);
					
					for(int i=0; i < 11; i ++) {
						sheet.autoSizeColumn(i);
					}
				    Row row = sheet.createRow((short)0);
				    row.setHeightInPoints(20);
				    setMergeCell(sheet, 0,0,0,9);
				    //
				    createCell(wb, row, (short) 0, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, "上报隐患数据统计---"+tjName);

				    Row title1 = sheet.createRow((short)1);
				    setMergeCell(sheet, 1,2,0,0);
				    setMergeCell(sheet, 1,1,1,3);
				    setMergeCell(sheet, 1,1,4,6);
				    setMergeCell(sheet, 1,1,7,9);
				    createCell(wb, title1, (short) 0, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, titleName);
				    createCell(wb, title1, (short) 2, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, "一般隐患");
				    createCell(wb, title1, (short) 5, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, "重大隐患");
				    createCell(wb, title1, (short) 8, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, "合计");
				    
				    Row title2 = sheet.createRow((short)2);
					createCell(wb, title2, (short) 1, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, "上报隐患数");
					createCell(wb, title2, (short) 2, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, "隐患整改数");
					createCell(wb, title2, (short) 3, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, "隐患整改率");
					createCell(wb, title2, (short) 4, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, "上报隐患数");
					createCell(wb, title2, (short) 5, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, "隐患整改数");
					createCell(wb, title2, (short) 6, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, "隐患整改率");
					createCell(wb, title2, (short) 7, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, "上报隐患数");
					createCell(wb, title2, (short) 8, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, "隐患整改数");
					createCell(wb, title2, (short) 9, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, "隐患整改率");
				    
					
					//set data 
					for(int i = 0; i < htmlList.size(); i ++) {
						Object[] obj = (Object[])htmlList.get(i);
						Row dataRow = sheet.createRow((short) i + 3);
						for(int j = 1; j < 11; j ++ ) {
							createCell(wb, dataRow, (short) (j-1), CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, obj[j].toString());
						}
					}
					
					HttpServletResponse response = this.contextPvd.getResponse();
					response.reset();
					
					response.setContentType("application/x-msdownload");
					response.addHeader("Content-Disposition","attachment; filename=\"" +java.net.URLEncoder.encode("上报隐患数据统计---"+tjName, "UTF-8")+".xls\"");
					ByteArrayOutputStream ostream = new ByteArrayOutputStream();
					ServletOutputStream servletOS = response.getOutputStream();
					wb.write(ostream);
					servletOS.write(ostream.toByteArray());
					servletOS.flush();
					servletOS.close();
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
			Loggers.error("TjZczbAction resultZczb（）异常 "+e.getMessage());
		}
	}
	
	
	/**
	 * 取得属地列表
	 * @param type 1:县区 2：乡镇
	 * @param selStr 县区的id
	 * @return
	 */
	public String getSdSql(String type,String selStr){
		try {
			TbUser user = (TbUser) this.contextPvd.getSessionAttr(Util.SESSION_ADMINUSER);
			String  gradeId = user.getTbUserGrade().getId().toString();
			StringBuilder sql = new StringBuilder("select t.id,t.dept_name from tb_user_dept t where 1=1 and t.dept_type=3");
			if("1".equals(type)){
				if("4".equals(gradeId) || "6".equals(gradeId) || "8".equals(gradeId)){//县区科室行业部门、县区行业、县区安委会
					sql.append(" and t.id="+user.getTbUserUnit().getId());
				}else if("7".equals(gradeId)){//乡镇
					sql.append(" and t.id="+user.getTbUserDept().getId());
				}else{
					sql.append(" and t.dept_parent_id="+this.getDeptByCode(Util.DEPT_CODE).getId());
				}
			}else{
				if("7".equals(gradeId)){//乡镇
					sql.append(" and t.id="+user.getTbUserDept().getId());
				}else{
					sql.append(" and t.dept_parent_id="+selStr);
				}
			}
			sql.append(" order by t.id");
			return sql.toString();
		} catch (Exception e) {
			e.printStackTrace();
			Loggers.error("TjZczbAction getSdSql（）异常 "+e.getMessage());
		}
		return null;
	}
	
	public TbUserDept getDeptByCode(String deptCode) throws Exception {
		List list = (List)this.utilService.getHqlQuery("from TbUserDept t where 1=1 and t.deptCode='"+deptCode+"'");
		if(null!=list && list.size()>0){
			return (TbUserDept)list.get(0);
		}
		return null;
	}
	
	/**
	 * 取得行业列表
	 * @return
	 */
	public String getHySql(){
		try {
			TbUser user = (TbUser) this.contextPvd.getSessionAttr(Util.SESSION_ADMINUSER);
			String  gradeId = user.getTbUserGrade().getId().toString();
			StringBuilder sql = new StringBuilder("select t.id,t.dept_name from tb_user_dept_view t where 1=1 and t.dept_grade=2 and ((t.dept_type=1 and t.dept_grade=2 and t.dept_class=3) or t.dept_type=2) ");
			if("3".equals(gradeId) && "3".equals(user.getTbUserDept().getDeptClass())){//市科室行业部门
				sql.append(" and t.id="+user.getTbUserDept().getId());
			}else if("4".equals(gradeId) && "3".equals(user.getTbUserDept().getDeptClass())){//县区科室行业部门
				
			}else if("5".equals(gradeId) && "1".equals(user.getTbUserUnit().getDeptClass())){//市行业
				sql.append(" and t.id="+user.getTbUserUnit().getId());
			}else if("6".equals(gradeId) && "1".equals(user.getTbUserDept().getDeptClass())){//县区行业
				sql.append(" and t.id="+user.getTbUserDept().getDeptSj());
			}
			sql.append(" order by t.dept_type,t.id");
			return sql.toString();
		} catch (Exception e) {
			e.printStackTrace();
			Loggers.error("TjZczbAction getHySql（）异常 "+e.getMessage());
		}
		return null;
	}
	
	/**
	 * 取得企业类型(大类)
	 * @return
	 */
	public String getTypeSql(){
		try {
			String sql = "";
			TbUser user = (TbUser) this.contextPvd.getSessionAttr(Util.SESSION_ADMINUSER);
			String grade = user.getTbUserGrade().getId().toString();//用户级别
			TbUserDept unit = null;
			TbUserDept dept = null;
			if(null!=user.getTbUserUnit()){
				unit = user.getTbUserUnit();
			}
			if(null!=user.getTbUserDept()){
				dept = user.getTbUserDept();
			}
			if("3".equals(grade) && "3".equals(dept.getDeptClass())){//市科室的行业科室
				sql = "select t.id,t.type_name from tb_corp_type t where 1=1 and t.id in(select distinct(x.type_parent_id) from tb_corp_type x where x.unit_id="+dept.getId()+" and x.is_dele=0)";
			}else if("4".equals(grade) && "3".equals(dept.getDeptClass())){//区科室
				sql = "select t.id,t.type_name from tb_corp_type t where 1=1 and t.id in(select distinct(x.type_parent_id) from tb_corp_type x where x.type_qudept_ids like '%"+dept.getId()+"%' and x.is_dele=0)";
			}else if("5".equals(grade) && "1".equals(unit.getDeptClass())){//市行业
				sql = "select t.id,t.type_name from tb_corp_type t where 1=1 and t.id in(select distinct(x.type_parent_id) from tb_corp_type x where x.unit_id="+unit.getId()+" and x.is_dele=0)";
			}else if("6".equals(grade) && "1".equals(dept.getDeptClass())){//区行业
				sql = "select t.id,t.type_name from tb_corp_type t where 1=1 and t.id in(select distinct(x.type_parent_id) from tb_corp_type x where x.unit_id="+dept.getDeptSj()+" and x.is_dele=0)";
			}else{
				sql = "select t.id,t.type_name from tb_corp_type t where 1=1 and t.type_parent_id=0";
			}
			sql += " and t.is_dele=0  order by t.id";
			return sql;
		} catch (Exception e) {
			e.printStackTrace();
			Loggers.error("TjZczbAction getHySql（）异常 "+e.getMessage());
		}
		return null;
	}
	
	/**
	 * 取得企业级别
	 * @return
	 */
	public String getGradeSql(){
		try {
			return "select t.id,t.grade_title from tb_corp_grade_type t where 1=1 and t.is_dele=0 order by t.id";
		} catch (Exception e) {
			e.printStackTrace();
			Loggers.error("TjZczbAction getGradeSql（）异常 "+e.getMessage());
		}
		return null;
	}

	public String getCMonth() {
		return cMonth;
	}

	public void setCMonth(String month) {
		cMonth = month;
	}

	public String getCYear() {
		return cYear;
	}

	public void setCYear(String year) {
		cYear = year;
	}

	public String getCType() {
		return cType;
	}

	public void setCType(String type) {
		cType = type;
	}

	public String getTitleName() {
		return titleName;
	}

	public void setTitleName(String titleName) {
		this.titleName = titleName;
	}

	public String getTjName() {
		return tjName;
	}

	public void setTjName(String tjName) {
		this.tjName = tjName;
	}

	public String getTjType() {
		return tjType;
	}

	public void setTjType(String tjType) {
		this.tjType = tjType;
	}

	public List getHtmlList() {
		return htmlList;
	}

	public void setHtmlList(List htmlList) {
		this.htmlList = htmlList;
	}

	public List getObjList() {
		return objList;
	}

	public void setObjList(List objList) {
		this.objList = objList;
	}

	public List getSumList() {
		return sumList;
	}

	public void setSumList(List sumList) {
		this.sumList = sumList;
	}

	public String getSelId() {
		return selId;
	}

	public void setSelId(String selId) {
		this.selId = selId;
	}

	public Map<Object[], List> getHtmlMap() {
		return htmlMap;
	}

	public void setHtmlMap(Map<Object[], List> htmlMap) {
		this.htmlMap = htmlMap;
	}

	public List getYearList() {
		return yearList;
	}

	public void setYearList(List yearList) {
		this.yearList = yearList;
	}

	public ChartParamBean getChartbean() {
		return chartbean;
	}

	public void setChartbean(ChartParamBean chartbean) {
		this.chartbean = chartbean;
	}

	public String getXmlString() {
		return xmlString;
	}

	public void setXmlString(String xmlString) {
		this.xmlString = xmlString;
	}

	public String getExportExcelFlag() {
		return exportExcelFlag;
	}

	public void setExportExcelFlag(String exportExcelFlag) {
		this.exportExcelFlag = exportExcelFlag;
	}
	
	/**
     * Creates a cell and aligns it a certain way.
     *
     * @param wb     the workbook
     * @param row    the row to create the cell in
     * @param column the column number to create the cell in
     * @param halign the horizontal alignment for the cell.
     */
    private static void createCell(Workbook wb, Row row, short column, short halign, short valign, String value) {
        Cell cell = row.createCell(column);
        cell.setCellValue(value);
        CellStyle style = wb.createCellStyle();
        style.setAlignment(halign);
        style.setVerticalAlignment(valign);
        
        /*Font titleFont = wb.createFont();
        titleFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
        //设置字体大小
        //titleFont.setFontHeightInPoints((short)8);
        //设置颜色
       // titleFont.setColor(IndexedColors.BLACK.getIndex());	   
	    style.setFont(titleFont);*/
	    
       cell.setCellStyle(style);
    }
    
    private void setMergeCell(Sheet sheet, int firstRow, int lastRow, int firstCol, int lastCol) {
    	 sheet.addMergedRegion(new CellRangeAddress(
 	            0, //first row (0-based)
 	            0, //last row  (0-based)
 	            0, //first column (0-based)
 	            9  //last column  (0-based)
 	    ));
    }

}
